#!/user/bin/env node

const http = require('https'),
      log = console.log,
      city = process.argv[2] || '石家庄';
let addr = 'https://api.66mz8.com/api/weather.php?location=' + city;

http.get(global.encodeURI(addr),(res)=>{
  log(`HTTP/${res.httpVersion}${res.statusCode}${res.statusMessage}`);
  log(res.headers);
  log();
  
  let data = '';   //解析数据
  res.on('data',chunk=>{
    data += chunk.toString('utf8');
  });
  res.on('end',()=>{
    //data = JSON.parse(data);
    log(data)
  });
  //log(data);
})
